/**
 * Copyright (C) 2022-2023
 * All rights reserved, Designed By www.tonetn.com
 * 注意：
 * 本软件为www.tonetn.com开发研制，未经购买不得使用
 * 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 * 一经发现盗用、分享等行为，将追究法律责任，后果自负
 */
package com.xunyin.modules.recharge.service.mapper;

import com.xunyin.common.mapper.CoreMapper;
import com.xunyin.modules.recharge.domain.TRechargeOrder;
import com.xunyin.modules.recharge.vo.TRechargeOrderVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author xunyinyunshang  <3594419785@qq.com>
 * @date 2022-10-12
 */
@Repository
public interface TRechargeOrderMapper extends CoreMapper<TRechargeOrder> {

    /**
     * 订单总金额
     * @return
     */
    @Select("select IFNULL(sum(order_money),0)/100  from t_recharge_order ")
    Double sumOrderMoney();

    /**
     * 实付订单总金额
     * @return
     */
    @Select("select IFNULL(sum(pay_money),0)/100 from t_recharge_order " +
            "where is_del=0 and order_status in (1,2,4) ")
    Double sumRealOrderMoney();


    /**
     * 充值订单管理-接口
     * @return
     */
    @Select("select sto.id,sto.order_money as orderMoney, sto.recharge_set_name as rechargeSetName,sto.pay_money as payMoney, " +
            " sto.phone,sto.order_time as orderTime,date_format(sto.order_time, '%m-%d %H:%i') as orderTimeStr " +
            " from t_recharge_order sto " +
            " where sto.order_status = 1 and order_time >= NOW() - interval 1 day " +
            " and sto.tea_house_id = #{storeId} " +
            " order by sto.order_time desc ")
    List<TRechargeOrderVo> getRechargeOrderByTeaHouseId(@Param("storeId") Integer storeId);
}
